﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using BusinessEntity;

namespace GDocsMobile
{
    public partial class FormOptions : Form
    {
        public FormOptions()
        {
            InitializeComponent();
        }

        private void CreateException(Exception ex)
        {
            MessageBox.Show(ex.Message, "GDocs Mobile Client", MessageBoxButtons.OK, MessageBoxIcon.None, MessageBoxDefaultButton.Button1);
        }

        private void menuItem1_Click(object sender, EventArgs e)
        {
            try
            {
                GDocs.SaveOptions(txtUsername.Text, txtPassword.Text);

                this.Close();
            }
            catch (Exception ex)
            {
                CreateException(ex);
            }
        }

        private void FormOptions_Load(object sender, EventArgs e)
        {
            try
            {
                string lsUsername, lsPassword;
                GDocs.LoadOptions(out lsUsername);

                txtUsername.Text = lsUsername;
            }
            catch (Exception ex)
            {
                CreateException(ex);
            }
        }

        private void menuItem4_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void menuItem3_Click(object sender, EventArgs e)
        {
            try
            {
                GDocs.ClearOptions();
                this.Close();

            }
            catch (Exception ex)
            {
                CreateException(ex);
            }
        }
    }
}